package com.briup.ch11;

import java.io.*;

/**
 * @author yuxi
 * @version 1.0
 * @date 2025/10/15
 * @Description:
 */
public class Test9 {
    public static void main(String[] args) throws IOException {
        /*OutputStream os1=new FileOutputStream("test.txt");
        os1.write('A');
        os1.write('B');
        os1.write('\t');
        os1.write(102);
        os1.write('\n');
        String str="hello world";
        byte[] bytes=str.getBytes();
        os1.write(bytes);
        os1.write(bytes);
        os1.write(bytes,5,3);
        os1.close();*/
        File f1=new File("1.jpg");
        File f2=new File("2.jpg");
        System.out.println(f2.exists());
        byte[] bytes=new byte[1024];
        int len=0;
        InputStream is1=new FileInputStream(f1);
        OutputStream os2=new FileOutputStream(f2);
        while((len=is1.read(bytes))!=-1){
            os2.write(bytes,0,len);
        }
        os2.close();//镜面对称，先关闭输出流，再关闭输入流
        is1.close();




    }
}
